import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { GuildWarPlayerCellRenderer } from "./cellRenderer/GuildWarPlayerCellRenderer";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
import { SGuildWarSingUpInfo } from "../../../../Message/Public/SGuildWarSingUpInfo";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { GTileList } from "../../../../com/mui/controls/GTileList";
type int = number;
//class GuildwarSignListWindow
    
    export  class GuildwarSignListWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(270, 362);
            title = Language.getString(41891);
            titleHeight = 26;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(19, 38, 230, 280, this);
            ObjCreate.createTextField(Language.getString(41892), 60, 46, 60, 20, this, GlobalStyle.textFormat2);
            ObjCreate.createTextField(Language.getString(41893), 173, 46, 60, 20, this, GlobalStyle.textFormat2);
            this._tileList = ObjCreate.createTileList(27, 67, 215, 255, this);
            this._tileList.setStyle("cellRenderer", GuildWarPlayerCellRenderer);
            this._tileList.columnWidth = 210;
            this._tileList.rowHeight = 25;
            this._pageSelecter = ObjCreate.createPageSelecter(57, 327, this, PageSelecter.CompleteMode);
            this._tfNum = ObjCreate.createTextField(Language.getStringByParam(41894, 0), 186, 329, 60, 20, this, GlobalStyle.textFormatGreen);
            this._pageSelecter.addEventListener(flash.events.Event.CHANGE, this.onChangePage);
            return;
        }

        /* internal  */onChangePage(arg1: Object /* flash.events.Event */): void
        {
            this.updatePageData();
            return;
        }

        public updateData(arg1: SGuildWarSingUpInfo): void
        {
            this.updateList(arg1.players);
            return;
        }

        /* internal  */updateList(arg1: Array<any>): void
        {
            this._aryPlayer = arg1;
            this._pageSelecter.maxPage = Math.ceil(arg1.length / this.pageSize);
            this.updatePageData();
            this._tfNum.text = Language.getStringByParam(41894, arg1.length);
            return;
        }

        /* internal  */updatePageData(): void
        {
            var loc1=this.pageSize * (this._pageSelecter.currentPage - 1);
            var loc2=Math.min(this.pageSize * this._pageSelecter.currentPage, this._aryPlayer.length);
            var loc3=[];
            var loc4=loc1;
            while (loc4 < loc2) 
            {
                loc3.push(this._aryPlayer[loc4]);
                ++loc4;
            }
            this._tileList.dataProvider = new DataProvider(loc3);
            return;
        }

        public static hasInstance(): Boolean
        {
            return !(GuildwarSignListWindow._instance == null);
        }

        public static get instance(): GuildwarSignListWindow
        {
            if (!GuildwarSignListWindow._instance) 
            {
                GuildwarSignListWindow._instance = new GuildwarSignListWindow();
            }
            return GuildwarSignListWindow._instance;
        }

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ /* var */_pageSelecter: PageSelecter;

        /* internal */ /* var */_tfNum: Object /* flash.text.TextField */;

        /* internal */ /* var */_aryPlayer: Array<any>;

        /* internal */ /* var */pageSize: int=10;

        /* internal */ static /* var */_instance: GuildwarSignListWindow;
    }
